package com.fashionbrot.github.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;


public class DoubleFormat extends JsonSerializer<Double> {


    @Override
    public void serialize(Double aDouble, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {

        if(aDouble != null) {
            jsonGenerator.writeNumber(DecimalFormatUtil.convert(aDouble));
        }else{
            jsonGenerator.writeNumber(0);
        }

    }

}
